package com.atjinggu.jinggumail.order.vo;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author jingming
 * @Type OrderConfirmVo.java
 * @Desc
 * @date 2021/3/7 23:25
 */
@Data
public class OrderConfirmVo {
    List<MemberAddressVo> address;

    List<OrderItemVo>  items;

    //发票信息

    //优惠券信息
    Integer integration;

    //订单总额
    BigDecimal total;

    public BigDecimal getTotal() {
        BigDecimal count = new BigDecimal("0");
        for (OrderItemVo item : items) {
            BigDecimal t= item.getPrice().multiply(new BigDecimal(item.getCount()));
            count = count.add(t);
        }
        return count;
    }

    //应付价格
    BigDecimal payPrice;

    public BigDecimal getPayPrice() {
        return getTotal();
    }

    //商品总件数
    Integer count;
    public Integer geCount() {
        int i = 0;
        for (OrderItemVo item : items) {
            i+=item.getCount();
        }
        return i;
    }




    //放重令牌
    String orderToken;

    //是否有库存
    Map<Long, Boolean> hasStock;

    @Data
    @NoArgsConstructor
    public static class OrderItemVo {
        private String skuId;
        private String image;
        private List<String> saleAttr;
        private String title;
        private BigDecimal price;
        private BigDecimal totalPrice;
        private Integer count;

    }

    @Data
    @NoArgsConstructor
    public static class OrderHasStock {
        private Long skuId;
        private Boolean hasStock;

    }

    @Data
    @NoArgsConstructor
    public static class MemberAddressVo {
        private Long id;
        /**
         * member_id
         */
        private Long memberId;
        /**
         * 收货人姓名
         */
        private String name;
        /**
         * 电话
         */
        private String phone;
        /**
         * 邮政编码
         */
        private String postCode;
        /**
         * 省份/直辖市
         */
        private String province;
        /**
         * 城市
         */
        private String city;
        /**
         * 区
         */
        private String region;
        /**
         * 详细地址(街道)
         */
        private String detailAddress;
        /**
         * 省市区代码
         */
        private String areacode;
        /**
         * 是否默认
         */
        private Integer defaultStatus;



    }
}